// pages/zaixianjianli/zaixianjianli.js
Page({

  /**
   * 页面的初始数据
   */
  
  data:{
    sex:'',
    exp:'',
    name:'',
    age:'',
    school:'',
    major:''
   },
   sex(e){
  //  console.log(e)
   this.setData({
   "sex":e.detail.value
   })
   },
   exp(e){
    //  console.log(e)
     this.setData({
     "exp":e.detail.value
     })
   },
   name(e){
  //  console.log(e)
   this.setData({
  "name":e.detail.value
   })
   },
   age(e){
  //  console.log(e)
   this.setData({
   "age":e.detail.value
   })
   },
   school(e){
   this.setData({
     "school":e.detail.value
   })
   },
   major(e){
    this.setData({
      "major":e.detail.value
    })
   },
selectImg: function () {
  var that = this;
  wx.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'],
    sourceType: ['album', 'camera'],
    success: function (res) {
      //res.tempFilePaths 返回图片本地文件路径列表
      var tempFilePaths = res.tempFilePaths;
      that.setData({
        imgPath: tempFilePaths[0]
      })

    }
  })

},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.login({
      success: res => {
         console.log(res)
         wx.request({
           url:'http://192.168.31.172:3000/getopenid',
           data:{
            "code":res.code
          },
           success:res=>{
             var openid=res.data.openid;
             console.log(openid)
            //  console.log(res)
             wx.setStorage({
               data: openid,
               key: 'openid',
             })
           }
           
         })
       },
     })
  },

  queding(e){
    console.log(this.data)
    wx.getStorage({
      key: 'openid',
      success:(res)=>{
        console.log(res)
        var that=this;
        wx.request({
          url: 'http://192.168.31.172:3000/grzl',
          method: 'POST',
          data:{
            "openid":res.data ,
            "sex":this.data.sex,
            "exp":this.data.exp,
            "name":this.data.name,
            "age":this.data.age,
            "school":this.data.school,
            "major":this.data.major
          },
          success:(result)=>{
            console.log(result)
            console.log("编辑成功")
          },
        })
      },
    })
    wx.navigateBack({
      complete: (res) => {},
    })
    },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})